/**
 * Copyright (c) 2011 Tomi Paananen.
 *
 * Part of Quick Gestures engine library.
 */

#ifndef __CLASSIFIERTHREAD_H__
#define __CLASSIFIERTHREAD_H__

// Qt includes
#include <QList>
#include <QThread>

// qgengine includes
#include "qgenginepriv.h"

// Forward declarations
class ClassifierIf;
class FeatureExtractor;
class Gesture;


class QGLIB_EXPORT ClassifierThread : public QThread
{
    Q_OBJECT

public: // Data types
    
    enum ClassifierStates {
        Idle = 0,
        Running
    };
    
public: // Construction and destruction
    explicit ClassifierThread(QObject *parent = 0);
    virtual ~ClassifierThread();

public:
    int state() const;
    ClassifierIf *classifier() const;
    void setClassifier(ClassifierIf *classifier);
    void setGestureSet(QList<Gesture*> gestureSet);
    void setGesture(Gesture *gesture);
    
protected: // From QThread
    void run();

private:
    void setState(ClassifierStates state);

public slots:
    void cancel();

signals:
    void stateChanged(int state);
    void succeeded(quint32 id, const QString &name);
    void failed(int error);
    void cancelled();
    void progress(int percentsComplete);
    
private: // Data
    ClassifierIf *m_classifier; // Owned
    FeatureExtractor *m_featureExtractor; // Owned
    QList<Gesture*> m_gestureSet; // Content not owned
    Gesture *m_gesture; // Not owned
    ClassifierStates m_state;
    bool m_doCancel;
};


#endif /* __CLASSIFIERTHREAD_H__ */

// End of file.
